//01部门商品，UPC前三位为021或前5位为00400,如果没有成对提交，
//则错误提示：01部门商品未成对提交
//(01散装部门会有一个进货码一个卖码，VSK码是相同的则定义为成对商品)
var result_51 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"", "MSG":"","DATA":"","RULE":"51"}');
var JSON_ITEM_LIST = !isNull(ITEM_LIST) ? JSON.parse(ITEM_LIST) : [];

//var LIST = !isNull(JSON_BULK_LIST) ? JSON.parse(JSON_BULK_LIST) : [];
var count = 0;
/*
var item_021;
var item_004;
function is01BULK(LIST, ITEM_LIST) {
  for (var i = 0; i < LIST.length; i++) {
    for (var j = 0; j < ITEM_LIST.length; j++) {
      if (LIST[i].ITEM_NBR == ITEM_LIST[j].ITEM_NBR) {
        if (LIST[i].UPC_NBR.toString().substr(0, 2) == '21') {
          item_021 = ITEM_LIST[j].ITEM_NBR;
        }
        if (LIST[i].UPC_NBR.toString().substr(0, 3) == '400') {
          item_004 = ITEM_LIST[j].ITEM_NBR;
        }
      }
    }
  }
}*/

function is01BULK(ITEM_LIST) {
  for (var j = 0; j < ITEM_LIST.length; j++) {
    if (item021 == ITEM_LIST[j].ITEM_NBR) {
      count = count + 1;
    } if (item004 == ITEM_LIST[j].ITEM_NBR) {
      count = count + 1;
    }
  }
  return count;
}


if (isDept01(DEPT_NBR, UPC_NBR,FINELINE) && is01BULK(JSON_ITEM_LIST) < 2) {
  result_51.CODE = 2;
  result_51.ACTION = "CHECKING_REPORT";
  result_51.MSG = "01部门商品未成对提交";
}
JSON.stringify(result_51);


